package br.com.felix.fwt.ui;

import java.io.PrintWriter;

import br.com.felix.fwt.ui.exception.ComponentRenderException;

public class Option extends BaseComponent {

	private static final long serialVersionUID = 6683868434958587039L;

	public boolean selected = false;
	public Option (String name, String value){
		setName(name);
		setValue(value);
	}
	
	
	@Override
	public void write(PrintWriter out) throws ComponentRenderException {
		if(!authorized()) return;
		out.write("\n<option value=\"");
		out.write(getValue());
		out.write("\" ");
		if(selected){
			out.write(" selected=\"selected\" ");
		}
		out.write(">\n");
		out.write(getName());
		out.write("\n</option>");
	}

}
